package collection.map;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/**
 * 遍历map集合的第一种方式，keySet
 */

public class Demo01MapPractice {
    public static void main(String[] args) {
        Map<String, String> map = new HashMap<>();
        map.put("007", "hello");
        map.put("002", "hello2");
        map.put("003", "hello3");
        map.put("004", "hello4");
        map.put("005", "hello5");

        Set<String> keys = map.keySet();
        for (String key : keys) {
            System.out.println(key + "=" + map.get(key));
        }

        Iterator<String> iterator = keys.iterator();
        while (iterator.hasNext()) {
            String key = iterator.next();
            System.out.println(key + "=" + map.get(key));
        }
    }
}
